<h1>Statement Bonus</h1>
<?php
$this->renderPartial('application.modules.member.views.main.info');
?>
<br />
<h2>Statement Bonus Anda Periode <?php echo function_lib::convert_date($date_start, 'text', '', 'ina'); ?> s.d. <?php echo function_lib::convert_date($date_end, 'text', '', 'ina'); ?></h2>
<link type="text/css" href="<?php echo Yii::app()->params['memberUrl']; ?>/addons/freezepanes/freezepanes-style.css" rel="stylesheet" />
<script type="text/javascript" src="<?php echo Yii::app()->params['memberUrl']; ?>/addons/freezepanes/freezepanes-js.js"></script>
<div class="add">
    <form action="" method="post" name="member_form">
        <table cellpadding="0" cellspacing="0">
            <tr class="title">
                <th colspan="5" style="text-align:left;"><strong>&nbsp;</strong></th>
            </tr>
            <tr>
                <th width="80">Lihat data</th>
                <td width="100" class="no-border">
                    <?php
                    $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                        'name' => 'date_start',
                        'value' => $date_start,
                        'options' => array(
                            'yearRange' => '-5:+0',
                            'showAnim' => 'fold',
                            'dateFormat' => 'yy-mm-dd', // save to db format
                            'altField' => '#self_pointing_id',
                            'altFormat' => 'yy-mm-dd', // show to user format
                            'changeYear' => true,
                        ),
                        'htmlOptions' => array(
                            'style' => 'padding:3px 4px;',
                            'size' => 10,
                        ),
                    ));
                    ?>
                </td>
                <td width="10" class="no-border">s.d.</td>
                <td width="100" class="no-border">
                    <?php
                    $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                        'name' => 'date_end',
                        'value' => $date_end,
                        'options' => array(
                            'yearRange' => '-5:+0',
                            'maxDate' => '-1d', //('y' for years, 'm' for months, 'w' for weeks, 'd' for days, e.g. '+1m +1w')
                            'showAnim' => 'fold',
                            'dateFormat' => 'yy-mm-dd', // save to db format
                            'altField' => '#self_pointing_id',
                            'altFormat' => 'yy-mm-dd', // show to user format
                            'changeYear' => true,
                        ),
                        'htmlOptions' => array(
                            'style' => 'padding:3px 4px;',
                            'size' => 10,
                        ),
                    ));
                    ?>
                </td>
                <td class="no-border"><input type="submit" name="search" class="button" value="Tampilkan" /></td>
            </tr>
        </table>
    </form>
</div>
<br />
<div class="div_freezepanes_wrapper">
    <div class="div_verticalscroll" style="cursor: pointer; ">
        <div style="height:50%;" onmousedown="upp();" onmouseup="upp(1);"><img class="buttonUp" src="<?php echo Yii::app()->baseUrl; ?>/images/icon/box-arrow-up.png" /></div>
        <div style="height:50%;" onmousedown="down();" onmouseup="down(1);"><img class="buttonDn" src="<?php echo Yii::app()->baseUrl; ?>/images/icon/box-arrow-down.png" /></div>
    </div>
    <div class="div_horizontalscroll" style="cursor: pointer; ">
        <div style="float:left; width:50%; height:100%;" onmousedown="right();" onmouseup="right(1);"><img class="buttonRight" src="<?php echo Yii::app()->baseUrl; ?>/images/icon/box-arrow-left.png" /></div>
        <div style="float:right; width:50%; height:100%;" onmousedown="left();" onmouseup="left(1);"><img class="buttonLeft" src="<?php echo Yii::app()->baseUrl; ?>/images/icon/box-arrow-right.png" /></div>
    </div>
    <div class="list">
        <table id="data-table" cellpadding="2" style="border:1px solid #999;">
            <tr>
                <th height="25">Tanggal</th>
                <th>Bonus</th>
                <th>Index</th>
                <th>Subtotal</th>
                <th>PPh</th>
                <th>Adm Fee</th>
                <th>Total</th>
            </tr>
            <?php
            $total_pph = $total_adm = 0;
            foreach ($data as $id => $row) {
                $pph = $adm = 0;
                if(strtotime($row['date']) < strtotime('2011-12-01')) {
                    $pph_percent = 3;
                    $pph = $row['adm'];
                    
                    $adm_percent = 0;
                    $adm = 0;
                } else {
                    $pph_percent = 3;
                    $pph = 0.3 * $row['adm'];
                    
                    $adm_percent = 7;
                    $adm = $row['adm'] - $pph;
                }
                $total_pph += $pph;
                $total_adm += $adm;
                
                echo '<tr>';
                echo '<th nowrap=""><a href="' . Yii::app()->baseUrl . '/member/bonus/statement_detail/' . $row['date'] . '">' . function_lib::convert_date($row['date'], 'text', '', 'ina') . '</a></th>';
                echo '<td nowrap="" align="right">' . number_format($row['bonus']) . '</td>';
                echo '<td nowrap="" align="right" style="color:#880000;">' . number_format($row['index']) . ' ('.$row['index_percent'].' %)</td>';
                echo '<td nowrap="" align="right">' . number_format($row['subtotal']) . '</td>';
                //echo '<td nowrap="" align="right">' . number_format($row['adm']) . ' ('.$row['adm_percent'].' %)</td>';
                echo '<td nowrap="" align="right" style="color:#880000;">' . number_format($pph) . ' ('.$pph_percent.' %)</td>';
                echo '<td nowrap="" align="right" style="color:#880000;">' . number_format($adm) . ' ('.$adm_percent.' %)</td>';
                echo '<th nowrap="" style="text-align:right;"><strong>' . number_format($row['total']) . '</strong></th>';
                echo '<td nowrap=""></td>';
                echo '</tr>';
            }
            ?>
            <tr>
                <th nowrap="" style="text-align:right;"><strong>TOTAL</strong></th>
                <th nowrap="" style="text-align:right;"><strong><?php echo number_format($total['bonus']); ?></strong></th>
                <th nowrap="" style="text-align:right; color:#880000;"><strong><?php echo number_format($total['index']); ?></strong></th>
                <th nowrap="" style="text-align:right;"><strong><?php echo number_format($total['subtotal']); ?></strong></th>
                <th nowrap="" style="text-align:right; color:#880000;"><strong><?php echo number_format($total_pph); ?></strong></th>
                <th nowrap="" style="text-align:right; color:#880000;"><strong><?php echo number_format($total_adm); ?></strong></th>
                <th nowrap="" style="text-align:right;"><strong><?php echo number_format($total['total']); ?></strong></th>
                <td nowrap=""></td>
            </tr>
        </table>
    </div>
</div>